/* 
 * Copyright (C) 2007 - 2010 Amerika Labs <http://amerika-labs.com/>
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 * 
 */

#include "ScriptPCH.h"
#include "Player.h"
#include "Unit.h"
#include <cstring>

#define CLOSE		pPlayer->CLOSE_GOSSIP_MENU()

#define Org		"Orgrimmar"
#define UC		"Undercity"
#define TB		"Thunder Bluff"
#define SM		"Silvermoon City"

#define SW		"Stormwind"
#define Darn		"Darnassus"
#define Ironf		"Ironforge"
#define Exodar		"The Exodar"

#define Shatt		"Shattrath City"
#define Dalaran		"Dalaran"
#define GMI		"GM Island"

class teleport_player : public CreatureScript
{
public:
	teleport_player() : CreatureScript("teleport_player") { }

/*	TeleportTo(map, X, Y, Z, Orient, 0)*/
bool OnGossipSelect(Player* pPlayer, Creature* pCreature, uint32 sender, uint32 uiAction) {
	switch (uiAction)
	{
		case GOSSIP_ACTION_INFO_DEF+1:
			pPlayer->TeleportTo(1, 1629.36, -4373.39, 31.256, 3.54, 0); 	// Orgrimmar
			break;
		case GOSSIP_ACTION_INFO_DEF+2:
			pPlayer->TeleportTo(0, 1584.07, 241.98, -52.153, 0.0496, 0);	// Undercity
			break;
		case GOSSIP_ACTION_INFO_DEF+3:
			pPlayer->TeleportTo(1, -1277.37, 124.804, 131.804, 5.22274, 0);	// Thunder Bluff
			break;
		case GOSSIP_ACTION_INFO_DEF+4:
			pPlayer->TeleportTo(530, 9487.69, -7279.2, 14.28, 6.16, 0);	// Silvermoon City
			break;
		case GOSSIP_ACTION_INFO_DEF+5:
			pPlayer->TeleportTo(0, -8833.38, 628.628, 94.0066, 1.06, 0);	// Stormwind
			break;
		case GOSSIP_ACTION_INFO_DEF+6:
			pPlayer->TeleportTo(1, 9949.56, 2284.21, 1341.4, 1.59, 0);	// Darnassus
			break;
		case GOSSIP_ACTION_INFO_DEF+7:
			pPlayer->TeleportTo(0, -5040.5, -814.81, 495.12, 5.49, 0);	//Ironforge
			break;
		case GOSSIP_ACTION_INFO_DEF+8:
			pPlayer->TeleportTo(530, -3965.7, -11653.6, 138.84, 0.852, 0);	// The Exodar
			break;
		case GOSSIP_ACTION_INFO_DEF+9:
			pPlayer->TeleportTo(530, -1838.16, 5301.7, -12.42, 5.95, 0);	// Shattrath
			break;
		case GOSSIP_ACTION_INFO_DEF+10:
			pPlayer->TeleportTo(571, 5804.15, 624.771, 647.767, 1.64, 0);	// Dalaran
			break;
		case GOSSIP_ACTION_INFO_DEF+11:
			pPlayer->TeleportTo(1, 16226.2, 16257, 13.2022, 1.65007, 0);	// GM Island
			break;
	}	// End Switch
		CLOSE;
	return true;
}	// End GossipSelect

bool OnGossipHello(Player* pPlayer, Creature* pCreature) {

	if (pPlayer->TeamForRace(pPlayer->getRace()) == HORDE | pPlayer->GetSession()->GetSecurity() > 0) {
		pPlayer->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, Org, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+1);
		pPlayer->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, UC, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+2);
		pPlayer->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, TB, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+3);
		pPlayer->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, SM, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+4);
	}

	if (pPlayer->TeamForRace(pPlayer->getRace()) == ALLIANCE | pPlayer->GetSession()->GetSecurity() > 0) {
		pPlayer->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, SW, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+5);
		pPlayer->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, Darn, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+6);
		pPlayer->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, Ironf, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+7);
		pPlayer->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, Exodar, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+8);
	}

	pPlayer->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, Shatt, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+9);
	pPlayer->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, Dalaran, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+10);
	pPlayer->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GMI, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+11);

	pPlayer->PlayerTalkClass->SendGossipMenu(100001, pCreature->GetGUID());

	return true;
}	// End GossipHello

};	// End class

void AddSC_teleport_player() {
	new teleport_player();
}
